class TourDaysController < ApplicationController
    
  layout 'admin'

  # GET /tour_days
  # GET /tour_days.json
  def index
    if params[:tid]
      @tour_days = TourDay.where('tour_id =?', params[:tid])

      respond_to do |format|
        format.js { render layout: false }
      end
    end
  end

  # GET /tour_days/1
  # GET /tour_days/1.json
  def show
    @tour_day = TourDay.find(params[:id])

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_days/new
  # GET /tour_days/new.json
  def new
    @tour_day = TourDay.new

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # GET /tour_days/1/edit
  def edit
    @tour_day = TourDay.find(params[:id])
  end

  # POST /tour_days
  # POST /tour_days.json
  def create
    @tour_day = TourDay.new(params[:tour_day])
    @tour_day.save
    @tour_days = TourDay.where('tour_id =?', @tour_day.tour_id)

    respond_to do |format|
      format.js { render layout: false }
    end
  end

  # PUT /tour_days/1
  # PUT /tour_days/1.json
  def update
    @tour_day = TourDay.find(params[:id])
    @tour_day.update_attributes(params[:tour_day])
    @tour_days = TourDay.where('tour_id =?', @tour_day.tour_id)

    respond_to do |format|
      format.js { render layout: false }
    end 
  end

  # DELETE /tour_days/1
  # DELETE /tour_days/1.json
  def destroy
    @tour_day = TourDay.find(params[:id])
    @tour_day.destroy
    @tour_days = TourDay.where('tour_id =?', params[:tid])

    respond_to do |format|
      format.js { render layout: false }
    end 
  end
end
